/*
  假RS485(uno 0,1脚) 与软串口(10,11脚) 之间的互传通讯。本程序可以作为今后串口Modbus调试的基础（通过软串口观察到底收到了什么） 
*/

#include <ArduinoRS485.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); //RX,TX
void setup() {
  mySerial.begin(9600);
  RS485.begin(9600);

  // enable transmission, can be disabled with: RS485.endTransmission();
  RS485.beginTransmission();

  // enable reception, can be disabled with: RS485.noReceive();
  RS485.receive();
}

void loop() {
  if (mySerial.available()) {
    RS485.write(mySerial.read());
  }

  if (RS485.available()) {
    mySerial.write(RS485.read());
  }
}
